package com.library.admin.listener;

import com.library.admin.Menu;
import com.library.admin.form.LoginForm;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Form;

public class HideFormListener implements ClickListener {
	private static final long serialVersionUID = -3305001726738865544L;
	
	private Form form;

	public HideFormListener(Form loginForm) {
		this.form = loginForm;
	}

	public void buttonClick(ClickEvent event) {
		Menu menu = (Menu) form.getParent();
		menu.removeComponent(form);
		
		if (form instanceof LoginForm) {
			menu.getConnectButton().setEnabled(true);
		}
	}
}
